package org.nlp2rdf.navigator.util;

import org.apache.log4j.Logger;

import java.io.File;

import org.dllearner.utilities.Files;

public class PathHelper {
	private static final Logger logger = Logger.getLogger(PathHelper.class);
	
	public static String fs = File.separator;
	
	public static String oneSlash(String path){
		path = removeSlash(path);
		return path+fs;
	}
	
	public static String removeSlash(String path){
		while(path.endsWith(fs)){
			path = path.substring(0,path.length()-2);
		}
		return path;
	}
	
	public static void exists(String path){
		String[] s = path.split(fs);
		String dirs = "";
		for (int i = 0; i < s.length; i++) {
			if(i>0){dirs+=fs;}
			dirs += s[i];
			if(!new File(dirs).isDirectory()){
				Files.mkdir(dirs);
				logger.info("created "+dirs);
			}
		}
		
	}
	

}
